/*
 * Copyright (C), 2010-2023, ATCOM Tech. Co., Ltd.
 *
 * File Name: libtest4.c
 * Author: liaoxuecheng
 * mail: liaoxuecheng@atcom.com.cn
 * Created Time: 2024年10月10日 星期四 15时28分31秒
 *
 */

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>

#define THIS_FILE "libtest4.c"

#define LINE_STR(a) #a
#define STR_LINE(a) LINE_STR(a)

char const __invoke_dynamic_linker__[] __attribute__ ((section (".interp")))
#ifdef __LP64__
= "/lib64/ld-linux-x86-64.so.2";
#else
= "/lib/ld-linux.so.2";
#endif


void my_start(void)
{
    printf("\033[33;1mThis is [%s:%d]\e[0m\n", __func__, __LINE__);
    _exit(0);
}

void my_init(void)
{
    printf("\033[33;1mThis is [%s:%d]\e[0m\n", __func__, __LINE__);
}

__attribute__((constructor)) static void beforeFunction()
{
    printf("\033[33;1mThis is [%s:%d]\e[0m\n", __func__, __LINE__);
}

__attribute__((destructor)) static void afterFunction()
{
    printf("\033[33;1mThis is [%s:%d]\e[0m\n", __func__, __LINE__);
}

static void __attribute__((constructor(125))) beforeFunction125()
{
    printf("\033[33;1mThis is [%s:%d] priority:125\e[0m\n", __func__, __LINE__);
}
static void __attribute__((destructor(125))) afterFunction125()
{
    printf("\033[33;1mThis is [%s:%d] priority:125\e[0m\n\n\n", __func__, __LINE__);
}

void my_fini(void)
{
    printf("\033[33;1mThis is [%s:%d]\e[0m\n\n\n", __func__, __LINE__);
}

int my_add(int a, int b)
{
    printf("\e[34;1mcall function %s [%s:%d]\e[0m\n", THIS_FILE, __func__, __LINE__);
    return a + b;
}
